package com.zw.stock_sell_storage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zw.stock_sell_storage.dto.SaleDetailDto;
import com.zw.stock_sell_storage.mapper.SaleDetailMapper;
import com.zw.stock_sell_storage.service.ISaleDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SaleDetailServiceImpl extends ServiceImpl<SaleDetailMapper, SaleDetailDto> implements ISaleDetailService {
    @Autowired
    SaleDetailMapper saleDetailMapper;
    @Override
    public List<SaleDetailDto> querySaleDetailByPurchasingId(int saleId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("fk_sale_id",saleId);
        return saleDetailMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public boolean addSaleDetail(List<SaleDetailDto> saleDetailList) {
        saleDetailMapper.insertSaleDetailList(saleDetailList);
        return true;
    }
}
